Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

The codebase had inconsistent endianness: bytes() used little-endian while Display (Base64) and serde used big-endian.

Changes

  • Display trait: Changed to_be_bytes()to_le_bytes() for Base64 encoding
  • Serde deserialization: Changed from_be_bytes()from_le_bytes() for Base64 decoding
  • Tests: Updated expected Base64 string and added verification test

Breaking Change

Base64 representation changes for the same FlakeId value:

let id = Flake::new(29866156537351941961353716432896);
println!("{}", id);
// Before: AAABePbBqL900Cue9CYAAA== (big-endian)
// After:  AAAm9J4r0HS/qMH2eAEAAA== (little-endian)

Systems storing or comparing Base64 representations will need to handle the migration.

Original prompt

This section details on the original issue you should resolve

<issue_title>Inconsistent endianness</issue_title>
<issue_description>The bytes() method uses little-endian, but Display (Base64) uses big-endian, and the serde implementation also uses big-endian. This inconsistency is confusing.

We should only use little endianness.</issue_description>

<agent_instructions>Change all code, tests and documentation to only use little endianness when converting from/to a FlakeId.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Jan 4, 2026
Co-authored-by: mantono <7093365+mantono@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix inconsistent endianness in FlakeId conversion Use little-endian consistently across all FlakeId conversions Jan 4, 2026
Copilot AI requested a review from mantono January 4, 2026 14:24
@mantono mantono marked this pull request as ready for review January 4, 2026 14:30
@mantono mantono closed this Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent endianness

2 participants